package com.settlement.system.service.impl;

import com.settlement.system.mapper.TblReceiveRefundAccountMapper;
import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.model.entity.common.SinglePage;
import com.settlement.system.model.entity.common.TblReceiveRefundAccount;
import com.settlement.system.service.ITblReceiveRefundAccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.settlement.system.mapper.BaseMapper;

import jakarta.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 收退款-账号 服务实现类
 *
 * @author Ximi
 * @since 2020-07-07
 */
@Service
@Slf4j
public class TblReceiveRefundAccountServiceImpl extends BaseServiceImpl implements ITblReceiveRefundAccountService {

    @Resource
    private TblReceiveRefundAccountMapper tblReceiveRefundAccountMapper;

    @Override
    public BaseMapper init() {
        return tblReceiveRefundAccountMapper;
    }

    @Override
    public List<TblReceiveRefundAccount> getAccount(String ncVirtualAccount,String checkAccountBookNo,String ncShopNo) throws ServiceException {
        try {
            return tblReceiveRefundAccountMapper.getAccount(ncVirtualAccount,checkAccountBookNo,ncShopNo);
        } catch (Exception ex){
            throw new ServiceException("根据NC虚拟账号,获取账号信息异常",ex);
        }
    }

    @Override
    public int getNcVirtualAccountCount(Map<String, Object> params) throws ServiceException {
        try {
            return tblReceiveRefundAccountMapper.getNcVirtualAccountCount(params);
        } catch (Exception ex){
            throw new ServiceException("根据NC虚拟账号,获取账号信息异常",ex);
        }
    }

    @Override
    public int getNcVirtualAccountNameCount(Map<String, Object> params) throws ServiceException {
        try {
            return tblReceiveRefundAccountMapper.getNcVirtualAccountNameCount(params);
        } catch (Exception ex){
            throw new ServiceException("根据NC虚拟账号,获取账号信息异常",ex);
        }
    }

    @Override
    public List<TblReceiveRefundAccount> getNcVirtualAccountList(SinglePage singlePage, Map<String, Object> params, String orderByField, String orderBy) throws ServiceException {
        try {
            return tblReceiveRefundAccountMapper.getNcVirtualAccountList(singlePage,params,orderByField,orderBy);
        } catch (Exception ex){
            throw new ServiceException("根据NC虚拟账号,获取账号信息异常",ex);
        }
    }

    @Override
    public List<TblReceiveRefundAccount> getNcVirtualAccountNameList(SinglePage singlePage, Map<String, Object> params, String orderByField, String orderBy) throws ServiceException {
        try {
            return tblReceiveRefundAccountMapper.getNcVirtualAccountNameList(singlePage,params,orderByField,orderBy);
        } catch (Exception ex){
            throw new ServiceException("根据NC虚拟账号,获取账号信息异常",ex);
        }
    }

    @Override
    public List<TblReceiveRefundAccount> getByNcVirtualAccount(String ncVirtualAccount) throws ServiceException {
        try {
            return tblReceiveRefundAccountMapper.getByNcVirtualAccount(ncVirtualAccount);
        } catch (Exception ex){
            log.error("Get ReceiveRefundAccount By NcVirtualAccount happen exception",ex);
            throw new ServiceException("Get ReceiveRefundAccount By NcVirtualAccount happen exception",ex);
        }
    }

    @Override
    public String getChannelNameByNcVirtualAccountName(String ncVirtualAccountName) throws ServiceException{
        try {
            return tblReceiveRefundAccountMapper.getChannelNameByNcVirtualAccountName(ncVirtualAccountName);
        } catch (Exception ex){
            log.error("Get ReceiveRefundAccount By ncVirtualAccountName happen exception",ex);
            throw new ServiceException("Get ReceiveRefundAccount By ncVirtualAccountName happen exception",ex);
        }
    }


    @Override
    public List<TblReceiveRefundAccount> getByNcEnterAccountBody(String ncEnterAccountBody) throws ServiceException {
        try {
            return tblReceiveRefundAccountMapper.getByNcEnterAccountBody(ncEnterAccountBody);
        } catch (Exception ex){
            log.error("Get ReceiveRefundAccount By NcEnterAccountBody happen exception",ex);
            throw new ServiceException("Get ReceiveRefundAccount By NcEnterAccountBody happen exception",ex);
        }
    }


    @Override
    public TblReceiveRefundAccount getOrByShopAccount(String shopAccount) throws ServiceException {
        try {
            return tblReceiveRefundAccountMapper.getOrByShopAccount(shopAccount);
        } catch (Exception ex){
            log.error("Get ReceiveRefundAccount By shopAccount happen exception",ex);
            throw new ServiceException("Get ReceiveRefundAccount By shopAccount happen exception",ex);
        }
    }

    @Override
    public TblReceiveRefundAccount selectExistAccount(TblReceiveRefundAccount account) throws ServiceException {
        try {
            return tblReceiveRefundAccountMapper.selectExistAccount(account);
        } catch (Exception ex){
            log.error("Get ReceiveRefundAccount By shopAccount happen exception",ex);
            throw new ServiceException("Get ReceiveRefundAccount By shopAccount happen exception",ex);
        }
    }

    @Override
    public TblReceiveRefundAccount getOrByLoginAccount(String loginAccount) throws ServiceException {
        try {
            return tblReceiveRefundAccountMapper.getOrByLoginAccount(loginAccount);
        } catch (Exception ex){
            log.error("Get ReceiveRefundAccount By loginAccount happen exception",ex);
            throw new ServiceException("Get ReceiveRefundAccount By loginAccount happen exception",ex);
        }
    }
}

